<script type="text/javascript">
    (function($){
        $(document).ready(function() {            
            var clone_id = 0;
            $('img.image').click(function(e) {                                
                $('#row_image' + clone_id).clone(true).attr('id', 'row_image' + (++clone_id)).appendTo('#body_car');
                e.preventDefault();
            });            
        });        
    })(jQuery);
</script>
<div id="content">
    <div class="container_medium">
        <div class="modelGroup1">
            <h1>
                Register your car
            </h1>
<?php  
            $attributes = array('class' => 'email', 'id' => 'targets'); 
            echo form_open_multipart(base_url()."index.php/car/submit", $attributes);
?>
            <table cellspacing="0" class="table_car">                
                <tbody id="body_car">
                    <tr>
                        <td>
                            <span class="mandatory">Member name</span>
                        </td>
                        <td style="width: 242px">
        <?php
                            echo $this->session->userdata('name');
        ?>                                                                
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span class="mandatory">Make</span>
                        </td>
                        <td>
                            <select id="make" name="make" class="mandatory">
                                <option value="" selected="selected">Please Select</option>
    <?php 
                            foreach($make->result() as $row)
                            { 
    ?>
                                <option value="<?php echo $row->id; ?>">
    <?php 
                                    echo $row->name; 
    ?>
                                </option>
    <?php
                            }
    ?>    
                            </select>
                        </td>
                    </tr>                  
                    <tr>
                        <td>
                            <span class="mandatory">Model</span>
                        </td>
                        <td>
                            <select id="model" name="model" title="" class="mandatory">
                                <option value="" selected="selected">Please Select</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span class="mandatory">Year</span>
                        </td>
                        <td>
                            <select id="year" name="year" title="" class="mandatory">
                                <option value="" selected="selected">Please Select</option>
    <?php 
                            $start_year = date("Y") + 1;
                            for($counter = $start_year; $counter >= 1953; $counter--)
                            { 
    ?>
                                <option value="<?php echo $counter; ?>">
    <?php 
                                    echo $counter; 
    ?>
                                </option>
    <?php
                            }
    ?>    
                            </select>
                        </td>
                    </tr>                  
                    <tr>
                        <td>
                            <span class="mandatory">Exterior Color</span>
                        </td>
                        <td>
                            <select id="external_color" name="external_color" title="" class="mandatory">
                                <option value="" selected="selected">Please Select</option>
    <?php 
                            foreach($color_external->result() as $row)
                            { 
    ?>
                                <option value="<?php echo $row->id; ?>">
    <?php 
                                    echo $row->color; 
    ?>
                                </option>
    <?php
                            }
    ?>    
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span class="mandatory">Interior Color</span>
                        </td>
                        <td>
                            <select id="internal_color" name="internal_color" title="" class="mandatory">
                                <option value="" selected="selected">Please Select</option>
    <?php 
                            foreach($color_internal->result() as $row)
                            { 
    ?>
                                <option value="<?php echo $row->id; ?>">
    <?php 
                                    echo $row->color; 
    ?>
                                </option>
    <?php
                            }
    ?>    
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span class="mandatory">Category</span>
                        </td>
                        <td>
                            <select id="category" name="category" title="" class="mandatory">
                                <option value="" selected="selected">Please Select</option>
    <?php 
                            foreach($category->result() as $row)
                            { 
    ?>
                                <option value="<?php echo $row->category_id; ?>">
    <?php 
                                    echo $row->category_name;
    ?>
                                </option>
    <?php
                            }
    ?>    
                            </select>
                        </td>
                    </tr>                
                    <tr>
                        <td>
                            <span class="mandatory">Type</span>
                        </td>
                        <td>
                            <select name="type" id="type" class="mandatory">
                                <option value="">Please select</option>
    <?php 
                            foreach($type->result() as $row)
                            { 
    ?>
                                <option value="<?php echo $row->id; ?>">
    <?php 
                                    echo $row->name;
    ?>
                                </option>
    <?php
                            }
    ?>    
                            </select>
                        </td>
                    </tr> 
                    <tr>
                        <td>VIN</td>
                        <td>
                            <input type="text" name="vehicle_id_number" id="vehicle_id_number" title="" size="30" value="" />
                        </td>
                    </tr>
                    <tr>
                        <td style="vertical-align: top;">Description</td>
                        <td>
                            <textarea name="description" id="description" title="" cols="40" rows="10"></textarea>
                        </td>
                    </tr>
                    <tr>
                        <td style="vertical-align: top;">Features</td>
                        <td>                        
                            <div id="car_feature">
                                <ul>
                                    <li style="background: none; padding-left: 0px;">
                                        Comfort
                                        <ul>
                                            <li>
                                                <input type="checkbox" name="feature_comfort[]" value="A/C: Front" />A/C: Front
                                            </li>
                                            <li>
                                                <input type="checkbox" name="feature_comfort[]" value="A/C: Rear" />A/C: Rear
                                            </li>
                                            <li>
                                                <input type="checkbox" name="feature_comfort[]" value="Cruise Control" />Cruise Control
                                            </li>
                                            <li>
                                                <input type="checkbox" name="feature_comfort[]" value="Navigation System" />Navigation System
                                            </li>
                                            <li>
                                                <input type="checkbox" name="feature_comfort[]" value="Power Locks" />Power Locks
                                            </li>
                                            <li>
                                                <input type="checkbox" name="feature_comfort[]" value="Power Steering" />Power Steering
                                            </li>
                                            <li>
                                                <input type="checkbox" name="feature_comfort[]" value="Remote Keyless Entry" />Remote Keyless Entry
                                            </li>
                                            <li>
                                                <input type="checkbox" name="feature_comfort[]" value="TV/VCR" />TV/VCR
                                            </li>
                                        </ul>
                                    </li>
                                    <li style="background: none; padding-left: 0px;">
                                        Safety
                                        <ul>
                                            <li>
                                                <input type="checkbox" name="feature_safety[]" value="Airbag: Driver" />Airbag: Driver
                                            </li>
                                            <li>
                                                <input type="checkbox" name="feature_safety[]" value="Airbag: Passenger" />Airbag: Passenger
                                            </li>
                                            <li>
                                                <input type="checkbox" name="feature_safety[]" value="Airbag: Side" />Airbag: Side
                                            </li>
                                            <li>
                                                <input type="checkbox" name="feature_safety[]" value="Alarm" />Alarm
                                            </li>
                                            <li>
                                                <input type="checkbox" name="feature_safety[]" value="Anti-Lock Brakes" />Anti-Lock Brakes
                                            </li>
                                            <li>
                                                <input type="checkbox" name="feature_safety[]" value="Power Locks" />Fog Lights
                                            </li>
                                        </ul>
                                    </li>
                                </ul>
                                <div style="clear: both;"></div>
                                <ul>
                                    <li style="background: none; padding-left: 0px;">
                                        Windows
                                        <ul>
                                            <li>
                                                <input type="checkbox" name="feature_window[]" value="Power Windows" />Power Windows
                                            </li>
                                            <li>
                                                <input type="checkbox" name="feature_window[]" value="Rear Window Defroster" />Rear Window Defroster
                                            </li>
                                            <li>
                                                <input type="checkbox" name="feature_window[]" value="Rear Window Wiper" />Rear Window Wiper
                                            </li>
                                            <li>
                                                <input type="checkbox" name="feature_window[]" value="Tinted Glass" />Tinted Glass
                                            </li>
                                        </ul>                                    
                                    </li>
                                    <li style="background: none; padding-left: 0px;">
                                        Sound System
                                        <ul>
                                            <li>
                                                <input type="checkbox" name="feature_sound[]" value="Cassette Radio" />Cassette Radio
                                            </li>
                                            <li>
                                                <input type="checkbox" name="feature_sound[]" value="CD Changer" />CD Changer
                                            </li>
                                            <li>
                                                <input type="checkbox" name="feature_sound[]" value="CD Player" />CD Player
                                            </li>
                                            <li>
                                                <input type="checkbox" name="feature_sound[]" value="Premium Sound" />Premium Sound
                                            </li>
                                            <li>
                                                <input type="checkbox" name="feature_sound[]" value="Bluetooth" />Bluetooth
                                            </li>
                                        </ul>                                    
                                    </li>                                
                                </ul>
                                <div style="clear: both;"></div>
                                <ul>
                                    <li style="background: none; padding-left: 0px;">
                                        Other
                                        <ul>
                                            <li>
                                                <input type="checkbox" name="feature_other[]" value="Alloy Wheels" />Alloy Wheels
                                            </li>
                                            <li>
                                                <input type="checkbox" name="feature_other[]" value="Sunroof/Moonroof" />Sunroof/Moonroof
                                            </li>
                                            <li>
                                                <input type="checkbox" name="feature_other[]" value="Third Row Seats" />Third Row Seats
                                            </li>
                                            <li>
                                                <input type="checkbox" name="feature_other[]" value="Tow Package" />Tow Package
                                            </li>
                                        </ul>                                    
                                    </li>
                                </ul>                            
                            </div>
                        </td>
                    </tr>                
                    <tr>
                        <td>Price</td>
                        <td>
                            <input type="text" name="price" id="price" title="" size="30" value="" />
                        </td>
                    </tr>
                    <tr>
                        <td>Mileage</td>
                        <td>
                            <input type="text" name="mileage" id="mileage" title="" size="30" value="" />
                        </td>
                    </tr>
                    <tr>
                        <td>Transmission</td>
                        <td>
                            <select id="transmission" name="transmission">
                                <option value="">Please Select</option>
    <?php 
                            foreach($transmission->result() as $row)
                            { 
    ?>
                                <option value="<?php echo $row->id; ?>">
    <?php 
                                    echo $row->transmission;
    ?>
                                </option>
    <?php
                            }
    ?>    
                            </select>                            
                        </td>
                    </tr>
                    <tr>
                        <td>Drive Train</td>
                        <td>
                            <select id="drive_train" name="drive_train" title="">
                                <option value="" selected="selected">Please Select</option>
    <?php 
                            foreach($drivetrain->result() as $row)
                            { 
    ?>
                                <option value="<?php echo $row->id; ?>">
    <?php 
                                    echo $row->drivetrain;
    ?>
                                </option>
    <?php
                            }
    ?>    
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td>Door Count</td>
                        <td>
                            <select id="door_count" name="door_count" title="">
                                <option value="" selected="selected">Please Select</option>
    <?php
                            for($counter = 1; $counter <= 10; $counter++)
                            {
    ?>
                                <option>
    <?php 
                                    echo $counter; 
    ?>
                                </option>
    <?php
                            }
    ?>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td style="vertical-align: top;">Fuel</td>
                        <td>
                            <ul>
    <?php 
                            foreach($fuel->result() as $row)
                            { 
    ?>
                            <li>
                                <input type="checkbox" name="fuel[]" id="fuel[]" title="" value="<?php echo $row->id; ?>" />
    <?php 
                                    echo $row->fuel;
    ?>
                            </li>
    <?php
                            }
    ?>                       
                            </ul>
                        </td>
                    </tr>         
                    <tr id="row_image0">
                        <td>Image</td>
                        <td>
                            <input type="file" name="userfile[]" multiple />
                        </td>
                    </tr>
                </tbody>
                <tfoot>
                    <tr>
                        <td colspan="2">&nbsp;</td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <input type="submit" name="submit" class="register" value="Register" />
                        </td>
                    </tr>                    
                </tfoot>
            </table>
<?php 
            echo form_close();
?>
        </div>
    </div>
    <div class="quicklink">
<?php 
        $this->load->view('/templates/quicklinks');
?>                        
    </div>    
</div>
<div class="separator"></div>
